Operators in Tiny Hexer Script are used to construct expressions.
|
|
Operators are used to build expressions by
taking an action on one or two parameters. Those parameters are called
operands. Operators taking one operand are unary operators,
operators taking two operands are called binary.
Unary operators (like @, - and
not) always precede their operand (e.g. -3).
Binary operators (like *, mod or
!=) are always placed between their operands (e.g. 3
* 4).
The operators + and - can be either
unary (e.g. -3) or binary (e.g. 4 -
3).
The behaviour of some of the operators depends on the data types of their operands (e.g. "ab" * 3 results in "ababab", 4 * 3 results in
12).
|
Numeric operators are used to do numeric calculations.
The following binary numeric operators exist in Tiny Hexer Script:
|
|
The following unary numeric operators exist in Tiny Hexer Script:
|
|
TEXT operators are used to modify TEXT string values.
The following binary TEXT operators exist in Tiny Hexer Script:
|
Relational operators are used to compare their two operands. Both
operands must be of compatible data
types, but FILE and VARREF types cannot be compared.
If comparsion succeeds, TRUE (=1) is returned, FALSE (=0) otherwise.
The following binary relational operators exist in Tiny Hexer Script:
|
The unary @ operator returns an expression of type
VARREF. Its operand must be a variable. This operator is used to store not only the
value of a variable, but a reference to the variable itself. To retrieve
the variable that is referenced by a VARREF expression, use the DEREF() function.
Some functions (like FILEREAD()) need
VARREF parameters to be able to get directaccess to the variable (e.g. for
variable tagging).
If you change the value of the variable that is referenced by a VARREF
expression, a DEREF() call always returns the actual value of that
variable, not the value that was stored at the time the assignment has been
made:
VAR a TEXT b TEXT r VARREF = assign a value to a a="foo" = store the value in b b=a = store the variable itself in r r=@a = now change the value of a a="bar" = b still contains "foo" MSGBOX b = r points to a, so the current value of a is shown MSGBOX DEREF(r)
|
In expressions containing multiple operators, the order of operator
computation depends on precedence rules. Operators with higher precedence
are evaluated before operators with lower precedence. To break those
precedence rules, you can use parenthesis:
4 + 3 * 7 → 25. The multiplication (3
* 7) is calculated before the sum (4 + 21), because
the * operator has a higher precedence than the + operator.
(4 + 3) * 7 → 49 breaks this rule because the sum is
calculated before the product.
Precedences (in descending order, the first operator has the highest precedence):
|